package it.polimi.swimv2.entities;

import it.polimi.swimv2.entities.User;
import java.io.Serializable;
import java.lang.Integer;
import java.lang.String;
import java.sql.Date;
import javax.persistence.*;

/**
 * 
 * Entity implementation class for Entity: Feedback. The entity Feedback
 * represents the feedback provided to an help request receiver.
 * 
 */
@Entity

@Table(name = "Feedback")
public class Feedback implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue
	@Column(name = "id", nullable = false)
	private Integer id;
	@ManyToOne
	private User author;
	@ManyToOne
	private User receiver;
	@Column(name = "date", nullable = false)
	private Date date;
	@Column(name = "score", nullable = false)
	private Integer score;
	@Column(name = "comment", nullable = false)
	private String comment;
	@ManyToOne
	private Ability ability;

	/**
	 * Default constructor for the class Feedback.
	 */
	public Feedback() {
		super();
	}

	/**
	 * Constructor for the class Feedback.
	 * 
	 * @param hr
	 *            the HelpRequest which generates the feedback.
	 * @param score
	 *            the score specified.
	 * @param comment
	 *            the content of the feedback.
	 */
	public Feedback(HelpRequest hr, int score, String comment) {
		this.author = hr.getSender();
		this.receiver = hr.getReceiver();
		this.setAbility(hr.getRequiredAbility());
		this.date = new Date(System.currentTimeMillis());
		this.score = score;
		this.comment = comment;
	}

	/**
	 * 
	 * @return the id of the feedback
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 * 
	 * @return the author of the feedback
	 */
	public User getAuthor() {
		return this.author;
	}

	/**
	 * 
	 * @param author
	 */
	public void setAuthor(User author) {
		this.author = author;
	}

	/**
	 * 
	 * @return the receiver of the feedback
	 */
	public User getReceiver() {
		return this.receiver;
	}

	/**
	 * 
	 * @param receiver
	 */
	public void setReceiver(User receiver) {
		this.receiver = receiver;
	}

	/**
	 * 
	 * @return the date on which the feedback was written.
	 */
	public Date getDate() {
		return this.date;
	}

	/**
	 * 
	 * @param date
	 */
	public void setDate(Date date) {
		this.date = date;
	}

	/**
	 * 
	 * @return the score
	 */
	public Integer getScore() {
		return this.score;
	}

	/**
	 * 
	 * @param score
	 *            the score to set
	 */
	public void setScore(Integer score) {
		this.score = score;
	}

	/**
	 * 
	 * @return the comment
	 */
	public String getComment() {
		return this.comment;
	}

	/**
	 * 
	 * @param comment
	 *            the comment to set.
	 */
	public void setComment(String comment) {
		this.comment = comment;
	}

	/**
	 * @return the ability
	 */
	public Ability getAbility() {
		return ability;
	}

	/**
	 * @param ability
	 *            the ability to set
	 */
	public void setAbility(Ability ability) {
		this.ability = ability;
	}

}
